import { http } from "@/utils/http";
import { baseUrlApi } from "./utils";
import type { aqiFeedbackType, monitorType } from "@/store/types";
export type FeedbackResult = {
  code: number;
  message: string;
  data: {
    list: {
      aqiFeedback: aqiFeedbackType;
      monitor: monitorType;
      imageUrl: string[];
    };
  };
};

/** 获取反馈列表 */
export const getFeedbackListDetail = (data: {
  aqiFeedbackParam: {};
  pageSize: number;
  pageNum: number;
}) => {
  return http.request<FeedbackResult>(
    "post",
    baseUrlApi(
      "/feedback/getFeedbackListDetail" +
        "?pageSize=" +
        data.pageSize +
        "&pageNum=" +
        data.pageNum
    ),
    {
      data: data.aqiFeedbackParam
    }
  );
};

/** 获取反馈表总页数 */
export const getFeedbackTotalPage = (data: {
  aqiFeedbackParam: {};
  pageSize: number;
}) => {
  return http.request<{ totalPage: number }>(
    "post",
    baseUrlApi(
      "/feedback/getFeedbackListTotalPage" + "?pageSize=" + data.pageSize
    ),
    {
      data: data.aqiFeedbackParam
    }
  );
};

/**指派反馈信息 */
export const assignFeedback = (fbId: number, insId: number) => {
  return http.request<Number>(
    "post",
    baseUrlApi("/feedback/assignAqiFeedback"),
    {
      params: {
        fbId: fbId,
        insId: insId
      }
    }
  );
};

/**根据反馈信息id获取反馈信息 */
export const getAqiFeedbackById = (fbId: number) => {
  return http.request<aqiFeedbackType>(
    "post",
    baseUrlApi("/feedback/getAqiFeedbackById"),
    {
      params: {
        fbId: fbId
      }
    }
  );
};

/**创建反馈信息 */
export const createAqiFeedback = (data: { aqiFeedback: aqiFeedbackType }) => {
  return http.request<number>(
    "post",
    baseUrlApi("/feedback/createAqiFeedback"),
    {
      data: data.aqiFeedback
    }
  );
};
